﻿package mortal.game.proxy
{
    import Framework.Util.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import flash.utils.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.utils.*;
    import mortal.mvc.core.*;

    public class PlayerProxy extends Proxy
    {

        public function PlayerProxy()
        {
            return;
        }// end function

        public function findMiniPlayerById(param1:Array, param2:int = 0) : void
        {
            if (param2 == 0)
            {
                rmi.iPlayerPrx.findMiniPlayerById_async(new AMI_IPlayer_findMiniPlayerById(this.getPlayerSucc, this.getPlayerFail), param1);
            }
            else
            {
                rmi.iPlayerPrx.findMiniPlayerById_async(new AMI_IPlayer_findMiniPlayerById(this.getPlayerSucc3), param1);
            }
            return;
        }// end function

        public function findMiniPlayerByName(param1:Array) : void
        {
            rmi.iPlayerPrx.findMiniPlayerByName_async(new AMI_IPlayer_findMiniPlayerByName(this.getPlayerSucc2, this.getPlayerFail), param1);
            return;
        }// end function

        private function getPlayerSucc(param1:AMI_IPlayer_findMiniPlayerById, param2:Array) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.GetRoleList, param2);
            return;
        }// end function

        private function getPlayerSucc2(param1:AMI_IPlayer_findMiniPlayerByName, param2:Array) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.GetRoleList, param2);
            return;
        }// end function

        private function getPlayerSucc3(param1:AMI_IPlayer_findMiniPlayerById, param2:Array) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.AddToRecent, param2);
            return;
        }// end function

        private function getPlayerFail(param1:Exception) : void
        {
            Log.debug("获取玩家失败");
            NetDispatcher.dispatchCmd(ServerCommand.GetRoleList, null);
            return;
        }// end function

        public function sendSignature(param1:String) : void
        {
            rmi.iPlayerPrx.sendSignature_async(new AMI_IPlayer_sendSignature(), param1);
            return;
        }// end function

        public function commitIssm(param1:String, param2:String) : void
        {
            rmi.iPlayerPrx.commitIssm_async(new AMI_IPlayer_commitIssm(this.commitIssmResponse), param1, param2);
            return;
        }// end function

        private function commitIssmResponse(param1:AMI_IPlayer_commitIssm, param2:int) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.IssmResult, param2);
            return;
        }// end function

        public function changeIssm(param1:int) : void
        {
            rmi.iTestPrx.changeIssm_async(new AMI_ITest_changeIssm(this.changeIssmResponse), param1);
            return;
        }// end function

        private function changeIssmResponse(param1:AMI_ITest_changeIssm, param2:int) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.IssmResult, param2);
            return;
        }// end function

        public function getVipReWard(param1:int, param2:int, param3:Function = null) : void
        {
            rmi.iPlayerPrx.getVipReward_async(new AMI_IPlayer_getVipReward(this.getVipRewardSuccess, null, param3), param1, param2);
            return;
        }// end function

        private function getVipRewardSuccess(param1:AMI_IPlayer_getVipReward, param2:Boolean) : void
        {
            var _loc_3:* = param1.userObject as Function;
            if (_loc_3 != null)
            {
                _loc_3.apply();
            }
            return;
        }// end function

        public function activeOnlineReward(param1:int) : void
        {
            rmi.iPlayerPrx.activeOnlineReward_async(new AMI_IPlayer_activeOnlineReward(this.activeSuccess), param1);
            return;
        }// end function

        private function activeSuccess(param1:AMI_IPlayer_activeOnlineReward) : void
        {
            return;
        }// end function

        public function investment(param1:int) : void
        {
            rmi.iPlayerPrx.invest_async(new AMI_IPlayer_invest(this.investSuccess, null, param1), param1);
            return;
        }// end function

        private function investSuccess(param1:AMI_IPlayer_invest) : void
        {
            var _loc_2:* = param1.userObject as int;
            var _loc_5:* = new Array();
            Cache.instance.investment.investmentDic[_loc_2] = new Array();
            var _loc_3:* = _loc_5;
            var _loc_4:* = new SInvestInfo();
            _loc_3.push(_loc_4);
            NetDispatcher.dispatchCmd(ServerCommand.InvestmentInfoUpdate, _loc_2);
            return;
        }// end function

        public function getinvest(param1:int, param2:int, param3:int) : void
        {
            var _loc_4:Object = {operType:param1, type:param2, day:param3};
            rmi.iPlayerPrx.getInvest_async(new AMI_IPlayer_getInvest(this.getSuccess, null, _loc_4), EInvestOper.convert(param1), param2, param3);
            return;
        }// end function

        private function getSuccess(param1:AMI_IPlayer_getInvest) : void
        {
            var _loc_5:Array = null;
            var _loc_2:* = param1.userObject.type;
            var _loc_3:* = Cache.instance.investment.getTodayInfoByType(_loc_2, param1.userObject.day);
            var _loc_4:* = Cache.instance.investment.investmentDic;
            if (_loc_3 == null)
            {
                _loc_3 = new SInvestInfo();
                _loc_5 = new Array();
                _loc_4[_loc_2] = _loc_5;
                _loc_5.push(_loc_3);
            }
            if (param1.userObject.operType == EInvestOper._EInvestGetToday)
            {
                _loc_3.isGetToday = true;
            }
            if (_loc_2 != EInvestType._EInvestTypeResigst)
            {
                if (InvestUtil.isHasGetAllInvest(param1.userObject.type))
                {
                    _loc_4[param1.userObject.type] = null;
                }
            }
            NetDispatcher.dispatchCmd(ServerCommand.InvestmentInfoUpdate, _loc_2);
            return;
        }// end function

        public function getHoleBossStat() : void
        {
            rmi.iPlayerPrx.getHoleBossStat_async(new AMI_IPlayer_getHoleBossStat(this.responseHoleBossStat));
            return;
        }// end function

        private function responseHoleBossStat(param1:AMI_IPlayer_getHoleBossStat, param2:int, param3:Dictionary) : void
        {
            Log.debug("获取世界Boss maxLevel:", param2);
            cache.copy.worldBoss.maxLevel = param2;
            cache.copy.worldBoss.bossStat = param3;
            NetDispatcher.dispatchCmd(ServerCommand.WorldBossStatChange, null);
            return;
        }// end function

        public function getMercenaryReward() : void
        {
            rmi.iPlayerPrx.getMyMercenaryMoney_async(new AMI_IPlayer_getMyMercenaryMoney());
            return;
        }// end function

        public function getRechargeTargetReward(param1:int) : void
        {
            rmi.iPlayerPrx.getEveryTotalRechargeRewards_async(new AMI_IPlayer_getEveryTotalRechargeRewards(this.getEveryTotalRechargeRewardsSuccess, null), param1);
            return;
        }// end function

        private function getEveryTotalRechargeRewardsSuccess(param1:AMI_IPlayer_getEveryTotalRechargeRewards) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RechargeDailyGetRwBack));
            return;
        }// end function

    }
}
